import { defineComponent, useSlots, ref, watch, computed, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, renderSlot, toDisplayString, createCommentVNode, Fragment } from "vue";
const _hoisted_1 = {
  key: 0,
  class: "me-loading-nested-text"
};
const _hoisted_2 = { key: 0 };
const _hoisted_3 = { class: "me-loading-dot" };
const _hoisted_4 = {
  key: 0,
  class: "me-loading-tip"
};
const _hoisted_5 = {
  key: 0,
  class: "me-loading-tip"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "me-loading"
  },
  __name: "loading",
  props: {
    tip: { default: "" },
    loading: { type: Boolean, default: true },
    size: { default: 9 },
    delay: { default: 0 }
  },
  setup(__props) {
    const slot = useSlots();
    const props = __props;
    const loading = ref(false);
    let timerId;
    watch([() => props.delay, () => props.loading], () => {
      const { delay } = props;
      timerId && clearTimeout(timerId);
      timerId = setTimeout(() => {
        loading.value = props.loading;
      }, delay);
    }, { immediate: true });
    const hasChild = computed(() => {
      return !!slot.default;
    });
    const sizeStyle = computed(() => {
      const { size } = props;
      return {
        width: `${size}px`,
        height: `${size}px`
      };
    });
    const fontStyle = computed(() => {
      const { size } = props;
      const fontSize = 2 * size + 2;
      return {
        fontSize: `${fontSize}px`
      };
    });
    return (_ctx, _cache) => {
      return hasChild.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
        loading.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
          createElementVNode("div", {
            class: normalizeClass(["me-loading", { "me-loading-loading": loading.value }])
          }, [
            createElementVNode("div", {
              style: normalizeStyle(fontStyle.value)
            }, [
              renderSlot(_ctx.$slots, "indicator", {}, () => [
                createElementVNode("div", _hoisted_3, [
                  createElementVNode("span", {
                    class: "me-loading-dot-item",
                    style: normalizeStyle(sizeStyle.value)
                  }, null, 4),
                  createElementVNode("span", {
                    class: "me-loading-dot-item",
                    style: normalizeStyle(sizeStyle.value)
                  }, null, 4),
                  createElementVNode("span", {
                    class: "me-loading-dot-item",
                    style: normalizeStyle(sizeStyle.value)
                  }, null, 4),
                  createElementVNode("span", {
                    class: "me-loading-dot-item",
                    style: normalizeStyle(sizeStyle.value)
                  }, null, 4)
                ])
              ])
            ], 4),
            renderSlot(_ctx.$slots, "tip", {}, () => [
              _ctx.tip ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(_ctx.tip), 1)) : createCommentVNode("", true)
            ])
          ], 2)
        ])) : createCommentVNode("", true),
        createElementVNode("div", {
          class: normalizeClass(["me-loading-container", { "me-loading-blur": loading.value }])
        }, [
          renderSlot(_ctx.$slots, "default")
        ], 2)
      ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
        loading.value ? (openBlock(), createElementBlock("div", {
          key: 0,
          class: normalizeClass(["me-loading", { "me-loading-loading": loading.value }])
        }, [
          createElementVNode("div", {
            style: normalizeStyle(fontStyle.value)
          }, [
            renderSlot(_ctx.$slots, "indicator", {}, () => [
              createElementVNode("div", {
                class: "me-loading-dot",
                style: normalizeStyle(fontStyle.value)
              }, [
                createElementVNode("span", {
                  class: "me-loading-dot-item",
                  style: normalizeStyle(sizeStyle.value)
                }, null, 4),
                createElementVNode("span", {
                  class: "me-loading-dot-item",
                  style: normalizeStyle(sizeStyle.value)
                }, null, 4),
                createElementVNode("span", {
                  class: "me-loading-dot-item",
                  style: normalizeStyle(sizeStyle.value)
                }, null, 4),
                createElementVNode("span", {
                  class: "me-loading-dot-item",
                  style: normalizeStyle(sizeStyle.value)
                }, null, 4)
              ], 4)
            ])
          ], 4),
          renderSlot(_ctx.$slots, "tip", {}, () => [
            _ctx.tip ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(_ctx.tip), 1)) : createCommentVNode("", true)
          ])
        ], 2)) : createCommentVNode("", true)
      ], 64));
    };
  }
});
export {
  _sfc_main as default
};
//# sourceMappingURL=loading.vue2.mjs.map
